﻿using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using bdnt_pets_system_Entity;
using System.Collections.Generic;
using bdnt_pets_system_Bo.DataManager;
using bdnt_pets_system_Bo.SystemManager;

namespace bdnt_pets_system.Web.Services
{
    [ServiceContract(Namespace = "")]
    //[SilverlightFaultBehavior]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class FailureService
    {
        [OperationContract]
        public void DoWork()
        {
            // 在此处添加操作实现
            return;
        }

        #region 缺陷采集管理
        FailureRecordManager fManager = new FailureRecordManager();

        [OperationContract]
        public bool SaveFailureRecor(Tbl_FailureRecord cuObj, List<SimpleObject<int, int>> fauilers)
        {
            return fManager.SaveObj(cuObj, fauilers);
        }

        [OperationContract]
        public List<Tbl_FailureRecord> GetFailureRecordListByCondition(string vINNO, string partNo, string partName, string failureName, int stationId,
           int checkerUserId, DateTime? sCheckTime, DateTime? eCheckTime, int isFx, int isZz,
            int pageSize, int currentPage, DateTime? sRecordTime, DateTime? eRecordTime, string productionNo, int recordUserId)
        {
            return fManager.GetObjListByCondition(vINNO, partNo, partName, failureName, stationId, checkerUserId, sCheckTime, eCheckTime,
                   isFx, isZz, pageSize, currentPage, sRecordTime, eRecordTime, productionNo, recordUserId);
        }

        [OperationContract]
        public int GetFailureRecordListByConditionCount(string vINNO, string partNo, string partName, string failureName, int stationId,
           int checkerUserId, DateTime? sCheckTime, DateTime? eCheckTime,
            int isFx, int isZz, DateTime? sRecordTime, DateTime? eRecordTime, string productionNo, int recordUserId)
        {
            return fManager.GetObjListByConditionCount(vINNO, partNo, partName, failureName, stationId, checkerUserId, sCheckTime, eCheckTime,
                isFx, isZz, sRecordTime, eRecordTime, productionNo, recordUserId);
        }

        [OperationContract]
        public bool UpdateFailureRecord(Tbl_FailureRecord cuObj)
        {
            return fManager.UpdateObj(cuObj);
        }

        [OperationContract]
        public bool DeleteFailureRecord(Int32 objId)
        {
            return fManager.DeleteObj(objId);
        }
        /// <summary>
        /// 保存故障记录并判断是否存在此车辆
        /// </summary>
        /// <param name="cuObj"></param>
        /// <param name="fauilers"></param>
        /// <returns></returns>
        [OperationContract]
        public Int32 NewAndSaveFailureRecord(Tbl_FailureRecord cuObj, List<SimpleObject<int, int>> fauilers)
        {
            return fManager.NewAndSaveFailureRecord(cuObj, fauilers);
        }
        #endregion

        #region 缺陷追踪
        FailureTrackingManager ftManager = new FailureTrackingManager();
        [OperationContract]
        public bool SaveFailureTracking(Tbl_FailureTracking cuObj)
        {
            return ftManager.SaveObj(cuObj);
        }
        [OperationContract]
        public List<Tbl_FailureTracking> GetFailureTrackingListByCondition(int cuEmpId, string partName, string failureName,
            DateTime? sTrakingTime, DateTime? eTrakingTime,
            int pageSize, int currentPage)
        {
            return ftManager.GetObjListByCondition(cuEmpId, partName, failureName, sTrakingTime, eTrakingTime, pageSize, currentPage);
        }
        [OperationContract]
        public int GetFailureTrackingListByConditionCount(int cuEmpId, string partName, string failureName,
            DateTime? sTrakingTime, DateTime? eTrakingTime)
        {
            return ftManager.GetObjListByConditionCount(cuEmpId, partName, failureName,
            sTrakingTime, eTrakingTime);
        }

        [OperationContract]
        public bool OverTracking(int objId)
        {
            return ftManager.OverTracking(objId);
        }

        [OperationContract]
        public bool UpdateTracking(Tbl_FailureTracking cuObj)
        {
            return ftManager.UpdateTracking(cuObj);
        }
        [OperationContract]
        public bool DeleteTracking(Int32 objId)
        {
            return ftManager.DeleteTracking(objId);
        }
        #endregion

        #region 缺陷描述
        [OperationContract]
        public List<Tbl_FailureTrackingDescr> SaveTrakingDescr(Tbl_FailureTrackingDescr cuObj)
        {
            return ftManager.SaveTrakingDescr(cuObj);
        }
        [OperationContract]
        public List<Tbl_FailureTrackingDescr> GetTrakingDescrByTrakingId(int objId)
        {
            return ftManager.GetTrakingDescrByTrakingId(objId);
        }

        #endregion

        #region 关键部件
        MatePartManager mtManager = new MatePartManager();
        [OperationContract]
        public Int32 SaveMatePart(List<Tbl_MatePart> cuObjs)
        {
            return mtManager.SaveObj(cuObjs);
        }
        [OperationContract]
        public bool SaveOneMatePart(Tbl_MatePart cuObj)
        {
            return mtManager.SaveOneObj(cuObj);
        }
        [OperationContract]
        public bool DeleteMatePart(Int32 objId)
        {
            return mtManager.DeleteObj(objId);
        }
        [OperationContract]
        public List<Tbl_MatePart> GetMatePartListByCondition(string vinNo, int pageSize, int currentPage, string stationIds)
        {
            return mtManager.GetObjListByCondition(vinNo, pageSize, currentPage, stationIds);
        }
        [OperationContract]
        public int GetMatePartListByConditionCount(string vinNo, string stationIds)
        {
            return mtManager.GetObjListByConditionCount(vinNo, stationIds);
        }

        [OperationContract]
        public List<Tbl_MatePart> GetMatePartStationListByConditon(string stationIds, string vinno)
        {
            return mtManager.GetMatePartStationListByConditon(stationIds, vinno);
        }
        #endregion

    }
}
